import http from "@/api";
import {ResultData, ResultPage} from "../utils/models";
import {
    RoleModel,
    UserModel,
    RequestMenuModel,
    RouteModel, RequestRoleModel, LoggerModel, LoginLogModel
} from "@/models/settingModel.ts";
import {FiltersModel} from "@/models/filterModel.ts";

// 获取菜单列表
export const getMenuListApi = () => {
    return http.post<ResultData<Menu.MenuOptions[]>>('/v1/setting/menu/list');
};
// 菜单过滤器
export const getMenuFilterApi = () => {
    return http.post<ResultData<FiltersModel>>('/v1/setting/menu/filter');
};
// 新增菜单
export const createMenuApi = (params: RequestMenuModel) => {
    return http.post<ResultData<Menu.MenuOptions>>('/v1/setting/menu/create', params);
};
// 修改菜单
export const updateMenuApi = (params: RequestMenuModel) => {
    return http.post<ResultData<RequestMenuModel>>('/v1/setting/menu/update', params);
};
// 获取接口路由
export const getRoutesApi = () => {
    return http.post<ResultData<RouteModel[]>>('/v1/setting/route/list');
};
// 删除菜单
export const deleteMenuApi = (params: { id: number }) => {
    return http.post<ResultData<Menu.MenuOptions>>('/v1/setting/menu/delete', params);
};

// 角色过滤器
export const getRoleFilterApi = () => {
    return http.post<ResultData<FiltersModel>>('/v1/setting/role/filter');
};
// 获取角色列表
export const getRoleListApi = (params: {}) => {
    return http.post<ResultPage<RoleModel[]>>('/v1/setting/role/list', params);
};
// 角色菜单菜单
export const getRoleMenusApi = () => {
    return http.post<ResultData<Menu.MenuOptions[]>>('/v1/setting/role/menus');
};
// 角色详情
export const getRoleDetailApi = (params: { id: number }) => {
    return http.post<ResultData<RoleModel>>('/v1/setting/role/detail', params);
};
// 角色新增
export const createRoleApi = (params: RequestRoleModel) => {
    return http.post<ResultData<RoleModel>>('/v1/setting/role/create', params);
};
// 角色修改
export const updateRoleApi = (params: RequestRoleModel) => {
    return http.post<ResultData<RoleModel>>('/v1/setting/role/update', params);
};
// 角色删除
export const deleteRoleApi = (params: { id: number }) => {
    return http.post<ResultData>('/v1/setting/role/delete', params);
};

// 用户过滤器
export const getUserFilterApi = () => {
    return http.post<ResultData<FiltersModel>>('/v1/setting/user/filter');
};
// 获取用户列表
export const getUserListApi = (params: {}) => {
    return http.post<ResultPage<UserModel[]>>('/v1/setting/user/list', params);
};
// 用户详情
export const getUserDetailApi = (params: { id: number }) => {
    return http.post<ResultData<UserModel>>('/v1/setting/user/detail', params);
};
// 角色列表
export const getUserRoleApi = (params: { name?: string }) => {
    return http.post<ResultData<RoleModel[]>>('/v1/setting/user/roles', params);
};
// 新增用户
export const createUserApi = (params: UserModel) => {
    return http.post<ResultData<UserModel>>('/v1/setting/user/create', params);
};
// 修改用户
export const updateUserApi = (params: UserModel) => {
    return http.post<ResultData<UserModel>>('/v1/setting/user/update', params);
};
// 用户重置密码
export const resetUserApi = (params: { id: number }) => {
    return http.post<ResultData>('/v1/setting/user/reset', params);
};
// 获取登录日志过滤器
export const getLoginLogFilterApi = () => {
    return http.post<ResultData<FiltersModel>>('/v1/setting/login/log/filter');
};
// 获取登录日志列表
export const getLoginLogListApi = (params: {}) => {
    return http.post<ResultPage<LoginLogModel>>('/v1/setting/login/log/list', params);
};
// 获取操作日志过滤器
export const getLoggerFilterApi = () => {
    return http.post<ResultData<FiltersModel>>('/v1/setting/logger/filter');
};
// 获取操作日志列表
export const getLoggerListApi = (params: {}) => {
    return http.post<ResultPage<LoggerModel>>('/v1/setting/logger/list', params);
};
// 操作日志详情
export const getLoggerDetailApi = (params: { id: number }) => {
    return http.post<ResultData<LoggerModel>>('/v1/setting/logger/detail', params);
};


